<?php include $this->admin_tpl("header"); ?>
<link rel="stylesheet" type="text/css" href="<?php echo JS_PATH;?>EasyUI/themes/haidaoblue/easyui.css">
<link rel="stylesheet" type="text/css" href="<?php echo JS_PATH;?>EasyUI/themes/icon.css">

<script type="text/javascript" src="<?php echo JS_PATH;?>EasyUI/jquery.min.js"></script>
<script type="text/javascript" src="<?php echo JS_PATH;?>EasyUI/jquery.easyui.min.js"></script>
<!-- Jquery 之 EasyUI插件引入 -->
<script type="text/javascript" src="<?php echo JS_PATH;?>EasyUI/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="<?php echo JS_PATH;?>EasyUI/hd_default_config.js"></script>

<div class="content">
	<div class="site">
		<?php echo C('site_name')?> <a href="#">会员管理</a> > 会员列表
	</div>
	<div id="cc" class="easyui-calendar"></div>

	<span class="line_white"></span>
	<!-- 搜索条件查询 -->
	<div class="goods mt10">
		<div class="guanli">
			<form action="<?php echo U('Member/lists'); ?>" method='post'>
				<!-- <span style="margin-right: 10px;">等级</span>
				<select name='user_type' id='group_combbox' class="easyui-combobox" data-options="editable:false,panelHeight:'auto'" style="height: 26px; width: 50px;"></select> -->

				<span style="margin-right: 10px;">状态</span>
				<select name='status' id='ban_combbox' class="easyui-combobox" data-options="editable:false,panelHeight:'auto'" style="height: 26px;width: 80px;"></select>

				<span style="margin-right: 10px;">实名认证</span>
				<select name='if_identification' id='renzheng_combbox' class="easyui-combobox" data-options="editable:false,panelHeight:'auto'" style="height: 26px;width: 80px;"></select>
				
				<span style="margin-right: 10px;">个人信息</span>
				<select name='if_complete' id='complete_combbox' class="easyui-combobox" data-options="editable:false,panelHeight:'auto'" style="height: 26px;width: 80px;"></select>


				<span style="margin-right: 10px;">推荐人</span>
				<select name='refer' id='refer_combbox' class="easyui-combobox" data-options="editable:false,panelHeight:'auto'" style="height: 26px;width: 80px;"></select>

				<span style="margin-right: 10px;">时间 </span>
				<input class="easyui-datebox" name="start" id="start" style="width: 100px;" data-options="sharedCalendar:'#cc'">
				<span style="margin-right: 10px;">至</span>
				<input class="easyui-datebox" name="end" id="end" style="width: 100px;" data-options="sharedCalendar:'#cc'" validType="md['#start']">

				<span style="margin-right: 10px;margin-left: 10px;">搜索</span>

				<!-- <select name='search_type' id='search_combbox' class="easyui-combobox" data-options="editable:false,panelHeight:'auto'" style="height: 26px;"></select> -->

				<input id="keyword" class="easyui-textbox" name="keyword" style="width:210px;height: 26px;" prompt="输入会员名/手机/均可搜索">
				<a id="search"href="#" class="easyui-linkbutton" style="height: 26px;padding-right: 10px;">查询</a>
			</form>
		</div>


		<div class="login mt10" style="border: none;">
			<table id="member_list" style="width:100%">
			</table>
			<div class="clear"></div>
		</div>


		<!-- 版权模块 -->
		<?php include $this->admin_tpl("copyright"); ?>
		<div class="clear"></div>
    </div>

	<!-- 余额设置 -->
    <div id="moneypanel" class="easyui-window"  style="width:320px;" closed="true" modal="true" minimizable="false" maximizable="false" collapsible="false" data-options="title:'修改余额'">
		<form id="SetMoneyForm" class="setmoneyform" method="post" action="<?php echo U('Member/set_balance'); ?>">
			<div class="login " style="border: none;">
			
				<div class="table">
					<table>
					<tr style="border-top: none;">
						<td>修改方式</td>
						<td align="left">
							<input type="radio" value="setInc" name="at" checked>增加 
							<input type="radio" value="setDec" name="at">减少
						</td>
						<td align="left"></td>
					</tr>
					<tr style="border-top: none;">
						<td>修改余额</td>
						<td align="left">
							<input type="text" value="0" style="margin:0;" class="text_input1" name="balance" >
						</td>
						<td align="left">变动的余额 如 10 </td>
					</tr>
					<tr style="border-bottom:1px solid #CCCCCC;border-top: none;">
						<td>修改原由</td>
						<td align="left" colspan="2">
							<input type="text" value="" style="margin:0;" class="input_ss" name="msg" >
						</td>
					</tr>
					</table>
				</div>
			</div>
			<div data-options="region:'south',border:false" style="text-align:right;padding:5px 20px;">
				<a class="easyui-linkbutton"  href="javascript:void(0)" onclick="$('#SetMoneyForm').submit()" style="padding: 0 10px;">确定</a>
				<a class="easyui-linkbutton"  href="javascript:void(0)" onclick="$('#moneypanel').window('close');" style="padding: 0 10px;">取消</a>
			</div>
			<input type="hidden" name="user_id" value="" />
		</form>
	</div>



	<!-- 升值链设置 -->
	<div id="poinospanel" class="easyui-window"  style="width:320px;" closed="true" modal="true" minimizable="false" maximizable="false" collapsible="false" data-options="title:'修改积分'">
		<form id="SetPoinosForm" class="setpoinosform" method="post" action="<?php echo U('Member/set_upvaluation'); ?>">
			<div class="login " style="border: none;">
				<!--<h3>设置积分</h3>-->
				<div class="table">
					<table>
					<tr style="border-top: none;">
						<td>修改方式</td>
						<td align="left"><input type="radio" value="setInc" name="at" checked>增加 <input type="radio" value="setDec" name="at">减少</td>
						<td align="left"></td>
					</tr>
					<tr style="border-top: none;">
						<td>修改升值链</td>
						<td align="left"><input type="text" value="0" style="margin:0;" class="text_input1" name="exp" ></td>
						<td align="left">变动的GF 如 10 </td>
					</tr>
					<tr style="border-bottom:1px solid #CCCCCC;border-top: none;">
						<td>修改原由</td>
						<td align="left" colspan="2"><input type="text" value="" style="margin:0;" class="input_ss" name="descript" ></td>
					</tr>
					</table>
				</div>
			</div>
			<div data-options="region:'south',border:false" style="text-align:right;padding:5px 20px;">
				<a class="easyui-linkbutton"  href="javascript:void(0)" onclick="$('#SetPoinosForm').submit()" style="padding: 0 10px;">确定</a>
				<a class="easyui-linkbutton"  href="javascript:void(0)" onclick="$('#poinospanel').window('close');" style="padding: 0 10px;">取消</a>
			</div>
			<input type="hidden" name="user_id" value="" />
		</form>
	</div>



</div>
<script type="text/javascript">
	var dom = $('#member_list');
	var pageSize = <?php echo PAGE_SIZE?>;//每页显示数量
	//会员增删改查
	var dataurl = '<?php echo U('lists')?>';
	var addurl = '<?php echo U('add')?>';
	var delurl = '<?php echo U('delete')?>';
	var editurl = '<?php echo U('edit')?>';

	


	var addressurl = '<?php echo U('MemberAddress/lists')?>';
	var rebateurl = '<?php echo U('Memberrebate/lists')?>';
	var sellrebateurl = '<?php echo U('Memberrebate/selllists')?>';
	var orderurl = '<?php echo U('Goods/AdminOrder/lists')?>';
	
	var renzheng = '<?php echo U('renzhegn_check') ?>';
	var repasswordurl = '<?php echo U('repassword')?>';
	var repinpassurl = '<?php echo U('repinpass')?>';
	// var setpotionsurl = '<?php echo U('setpoints')?>';
	$(function(){
		//js创建数据表格
		var memlist = dom.datagrid({
			url:dataurl,//从远程站点请求数据的 URL
			striped:true,//true 把行条纹化。（即奇偶行使用不同背景色）
			width:'100%',
			title:"统计概览",  
			fitColumns:true,//会自动扩大或缩小列的尺寸以适应网格的宽度并且防止水平滚动
			checkOnSelect:true,//true，当用户点击某一行时，则会选中/取消选中复选框。
			//如果设置为 false 时，只有当用户点击了复选框时，才会选中/取消选中复选框。
			toolbar:[
				{
					id:'addrow',
					text:'添加',
					iconCls:'icon-add',
				},'-'
			],
			frozenColumns:[[
				{field:'id',checkbox:true}
			]],
			pagination:true,
			pageSize:pageSize,
			pageList: [pageSize,pageSize*2,pageSize*4],//可以设置每页记录条数的列表
			frozenColumns:[[
				{field:'id',title:'ID',fixed:true,align:'center',width:'5%'},
				{field:'username',title:'会员名',fixed:true,align:'center',width:'10%'},
				//没有定义宽度将会降低性能	
			]],
			columns:[[
				{field:'status',title:'状态',halign:'center',align:'center',width:'4%',sortable:true,
					formatter:function(value,row,index){
						if(value==2){
							return "<span class=red>冻结</span>";
						}else if(value == 1){
							return "正常";
						}
					}
					
				},			
				{field:'if_identification',title:'认证',halign:'center',align:'center',width:'4%',sortable:true,
					formatter:function(value,row,index){
						if(value==3){
							return "已认证";
						}else if(value == 2){
							return "<span class=red>审核中</span>";
						}else if(value == 4){
							return "<span class=red>审核未通过</span>";
						}else if(value == 1){
							return "<span class=red>未上传</span>";
						}
					}
					
				},
				{field:'if_complete',title:'个人信息',halign:'center',align:'center',width:'4%',sortable:true,
					formatter:function(value,row,index){
						if(value==1){
							return "已完善";
						}else{
							return "<span class=red>未完善</span>";
						}
					}
					
				},
						
				
				{field:'nickname',title:'昵称',align:'center',width:'6%',align:'center'},
				{field:'real_name',title:'真实姓名',align:'center',width:'6%',align:'center'},
				{field:'refer_username',title:'推荐人账号',align:'center',width:'6%',align:'center'},
				{field:'balance',title:'余额',width:'10%',align:'center',sortable:true},
				{field:'freeze_balance',title:'冻结金额',width:'10%',align:'center',sortable:true},
				{field:'upvaluation',title:'升值链(GF)',width:'10%',align:'center',sortable:true},
				{field:'freeze_upvaluation',title:'冻结GF',width:'10%',align:'center',sortable:true},
			
				{field:'register_time',title:'注册时间',width:'10%',align:'center',sortable:false},

				{field:'userID',title:'操作',width:'28%',align:'center',halign:'center',
					formatter:function(value,row,index){
						var sp_txt="&nbsp;&nbsp;&nbsp;&nbsp;";
						return '<a  href="/index.php?m=user&c=member&a=dologin&username='+row.username+'" target="_blank">登录</a>'+sp_txt+
						'<a  href="javascript:void (0)" onclick="alert_balance('+row.id+','+index+')">余额</a>'+sp_txt+
						'<a  href="javascript:void (0)" onclick="alert_upvaluation('+row.id+','+index+')">升值链</a>'+sp_txt+
									'<a  href="'+editurl+'&id='+row.id+'&if_upd=1">编辑</a>'+sp_txt+
									'<a  href="'+repasswordurl+'&id='+row.id+'">重置密码</a>'+sp_txt+
									'<a  href="'+repinpassurl+'&id='+row.id+'">重置二级密码</a>'
						// if(row.if_identification == 2){
						// 	return '<a  href="/index.php?m=user&c=member&a=dologin&username='+row.username+'" target="_blank">登录</a>'+sp_txt+
						// 			'<a  href="'+editurl+'&id='+row.id+'&if_upd=1">编辑</a>'+sp_txt+
						// 			'<a  href="'+repasswordurl+'&id='+row.id+'">重置密码</a>'+sp_txt+
						// 			'<a  href="'+repinpassurl+'&id='+row.id+'">重置二级密码</a>'
						// 			// '<a  href="'+renzheng+'&id='+row.id+'">实名认证审核</a>';

						// }else{
						// 	return '<a  href="/index.php?m=user&c=member&a=dologin&username='+row.username+'" target="_blank">登录</a>'+sp_txt+
						// 			'<a  href="'+editurl+'&id='+row.id+'&if_upd=1">编辑</a>'+sp_txt+
						// 			'<a  href="'+repasswordurl+'&id='+row.id+'">重置密码</a>'+sp_txt+
						// 			'<a  href="'+repinpassurl+'&id='+row.id+'">重置二级密码</a>';
						// }
						
					}
				},
			]],
			onLoadSuccess:function(data){
				$(".panel-title").eq(0).html(data.title);
				var ban = data.status;
				ban.unshift({"id":"","name":"请选择"})
				$('#ban_combbox').combobox({
					data:ban,
					valueField:'id',
					textField:'name'
				});
				var renzheng = data.if_identification;
				renzheng.unshift({"id":"","name":"请选择"})
				$('#renzheng_combbox').combobox({
					data:renzheng,
					valueField:'id',
					textField:'name'
				});
				
				var if_complete = data.if_complete;
				if_complete.unshift({"id":"","name":"请选择"})
				$('#complete_combbox').combobox({
					data:if_complete,
					valueField:'id',
					textField:'name'
				});
				var refer = data.refer;
				refer.unshift({"id":"","name":"请选择"})
				$('#refer_combbox').combobox({
					data:refer,
					valueField:'id',
					textField:'name'
				});
			}
		});
		//回车查询
		$('#keyword').textbox('textbox').bind('keydown',function (e) {
			if (e.keyCode == 13) {
				$('#search').trigger('click');
			}
		});
		//增加查询参数，重新加载表格
		$('#search').bind('click',function (){
			var queryParams = dom.datagrid('options').queryParams;
			queryParams.start = $('#start').datebox('getValue');
			queryParams.end = $('#end').datebox('getValue');
			queryParams.keyword = $("#keyword").val();
			// queryParams.user_type = $('#group_combbox').combobox('getValue');
			queryParams.status = $('#ban_combbox').combobox('getValue');
			queryParams.if_identification = $('#renzheng_combbox').combobox('getValue');
			queryParams.if_complete = $('#complete_combbox').combobox('getValue');
			queryParams.refer = $('#refer_combbox').combobox('getValue');
			dom.datagrid('options').queryParams = queryParams;
			dom.datagrid('reload');
		})
		//添加会员
		$('#addrow').bind('click',function(){
			window.location.href=addurl;
		})
		//删除操作
		$('#delrows').bind('click', function(){
			$.messager.alert('警告','请不要进行删除操作！');
			return false;

			var ids = [];
			var rows = dom.datagrid('getChecked');
			for(var i=0; i<rows.length; i++){
				ids.push(rows[i].id);
			}
			if (ids.length > 0){
				$.messager.confirm('确认','您确认想要删除记录吗？',function(r){
					if (r){
						$.getJSON(delurl,
						{"id[]":ids},
						function(data){
							if(1 == data.status){// 删除成功，则需要在树中删除节点
								// 检修任务grid 执行load
								dom.datagrid("reload");  //重新加载
							}else{
								$.messager.alert('警告',data.info);
							}
						})
					}else{
						dom.datagrid('clearSelections').datagrid('clearChecked');
					}
				});
			}else{
				$.messager.alert('警告','请选择要删除的记录');
				return false;
			}
		});
	});
	//积分弹窗
	function pay_points(value,index){
		$('input[name="user_id"]').val(value);
		$('#poinospanel').window('open');
	}
	//经验
	function exp(value,index){
		$('input[name="user_id"]').val(value);
		$('#exppanel').window('open');
	}
	// 余额
	function user_money(value,index) {
		$('input[name="user_id"]').val(value);
		$('#moneypanel').window('open');
	}




	function alert_balance(value,index) {
		$('input[name="user_id"]').val(value);
		$('#moneypanel').window('open');
	}

	function alert_upvaluation(value,index) {
		$('input[name="user_id"]').val(value);
		$('#poinospanel').window('open');
	}
</script>